// 封装用户相关操作
import ajax from '../utils/request.js'
// 获取评论请求
export const getComment = (articleId, offset) => {
  return ajax({
    url: '/app/v1_0/comments',
    method: 'GET',
    params: {
      type: 'a',
      source: articleId,
      offset
    }
  })
}
// 发表评论
export const sendComment = (articleId, content) => {
  return ajax({
    url: '/app/v1_0/comments',
    method: 'POST',
    data: {
      target: articleId,
      content
    }
  })
}
// 评论点赞
export const likeComment = (commentId) => {
  return ajax({
    url: '/app/v1_0/comment/likings',
    method: 'POST',
    data: {
      target: commentId
    }
  })
}
// 取消评论点赞
export const dislikeComment = (commentId) => {
  return ajax({
    url: '/app/v1_0/comment/likings/' + commentId,
    method: 'DELETE'
  })
}
// 获取回复
export const getReplay = (commentId, offset) => {
  return ajax({
    url: '/app/v1_0/comments',
    method: 'GET',
    params: {
      type: 'c',
      source: commentId,
      offset
    }
  })
}
// 添加回复
export const sendReplay = (commentId, content, articleId) => {
  return ajax({
    url: '/app/v1_0/comments',
    method: 'POST',
    data: {
      target: commentId,
      content,
      art_id: articleId
    }
  })
}
